﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Security.Cryptography;

namespace VxiServer
{
    class PolCode0x14 : PolCode
    {
        public override byte Code
        {
            get { return 0x14; }
        }

        public override void Work(TcpClient client, string ipAddress, byte[] buffer)
        {
            int contentID = buffer[0x1C];
            contentID += buffer[0x1D] << 8;
            contentID += buffer[0x1E] << 16;
            contentID += buffer[0x1F] << 24;

            int charID = buffer[0x20];
            charID += buffer[0x21] << 8;
            charID += buffer[0x22] << 16;
            charID += buffer[0x23] << 24;

            byte[] packet1 = new byte[] {
			0x20, 0x00, 0x00, 0x00, 0x49, 0x58, 0x46, 0x46, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00 };

            MD5 md5Hasher = MD5.Create();
            byte[] data = md5Hasher.ComputeHash(packet1);

            Buffer.BlockCopy(data, 0, packet1, 12, data.Length);
            client.Client.Send(packet1.Take(20).ToArray());

        }
    }
}
